#ifndef WALL_H_
#define WALL_H_

//#include "map.h"

/* classify a point respect to an hyperplane (>=0 the point is above the plane, <0 the point is below the plane */
#define getSign(h,p) ((h)[0]*(p)[0]+(h)[1]*(p)[1]+(h)[2])
/*STRUTTURE*/
#include "vector.h"
#define NUMBER_OF_WALLS 51	//28	//numero totale di muri
#define NUMBER_OF_WALLS_S1 4
#define NUMBER_OF_WALLS_S2 4
#define NUMBER_OF_WALLS_S3 4
#define NUMBER_OF_WALLS_S4 4
#define NUMBER_OF_WALLS_S5 4
#define NUMBER_OF_WALLS_C1 2
#define NUMBER_OF_WALLS_C2 2
#define NUMBER_OF_WALLS_C3 2
#define NUMBER_OF_WALLS_C4 2

#define NUMBER_OF_ROOM 9
#define STANZA1	1
#define STANZA2	2
#define STANZA3	3
#define STANZA4	4
#define STANZA5	5

#define CORRIDOIO11	6
#define CORRIDOIO12	7
#define CORRIDOIO13	8
#define CORRIDOIO14	9

/*	muri intorno alle torrette: 2 per ogni cannone	*/
#define NUMBER_OF_WALLS_CNO 2
#define NUMBER_OF_WALLS_CNE 2
#define NUMBER_OF_WALLS_CSO 2
#define NUMBER_OF_WALLS_CSE 2

#define WALL_STRIPE 0
#define WALL_END    0



extern float S1N[];
extern float S1S[];
extern float S1W[];
extern float S1E[];

extern float S2N[];
extern float S2S[];
extern float S2W[];
extern float S2E[];

extern float S3N[];
extern float S3S[];
extern float S3W[];
extern float S3E[];

extern float S4N[];
extern float S4S[];
extern float S4W[];
extern float S4E[];

extern float S5N[];
extern float S5S[];
extern float S5W[];
extern float S5E[];


struct wall_t
{
	int dimTot;			/* dimensione totale del muro*/
	float  point[2];	/* point of application */
	float  dir  [2];	/* main direction of the wall, must me normalized! */
	float  *w;			/* description of the wall */
	float  size;		/* size of the wall */
};

extern struct wall_t walls[NUMBER_OF_WALLS];

typedef struct room_t{
	GLfloat x1; 		// coordinate che definiscono il perimetro della stanza
	GLfloat y1;
	GLfloat x2;
	GLfloat y2;
} room_t;

int isInRoom(room_t* roomMap,float eye_x, float eye_y);

void findPlane(float dest[3],float p0[2],float p1[2]);
int acrossWall(struct wall_t* wall,float Start[2],float End[2], struct wall_t* last_crossed_wall);
void drawWall(struct wall_t* wall);
void disegnaMuroPrincipale();
void disegnaMappa(	
	GLfloat eyex, GLfloat eyey,	GLfloat eyez, 
	GLfloat targetx, GLfloat targety, GLfloat targetz 
);
void initWalls(struct wall_t* walls);
void checkMovement(float Start[2],float End[2], struct wall_t* last_crossed_wall);
room_t* initRooms();

#endif //WAL_H_


